package leetcode.offer;

import java.util.Arrays;

/**
 * ClassName: Offer45_MinNumber
 * Description: leetcode - 剑指offer 把数组排成最小的数
 * date: 2021-11-11 9:40
 *
 * @author liyifan
 */
public class Offer45_MinNumber {
    public String minNumber(int[] nums){
        String[] array = Arrays.stream(nums).mapToObj(String::valueOf).toArray(String[]::new);
        Arrays.sort(array, (s1, s2) -> {
            return (s1 + s2).compareTo((s2 + s1));
        });
        StringBuffer buffer = new StringBuffer();
        for(String s:array) {
            buffer.append(s);
        }
        return buffer.toString();
    }
}
